home *** CD-ROM | disk | FTP | other *** search
- /* search for this pattern… */
- /* <------look at this! */
- /* and this pattern */
- /* cw5 */
- /* and this pattern */
- /* look at this */
- /* cur defined in Globals.c */
-
- /****************************************************************************************/
- /* PredatorPrey Network Game */
- /* James C. Ullrey */
- /* INRESCO */
- /* © 1995 */
- /* Version 3.97a */
- /* */
- /* Use LJ Courier 10, tabs 2 */
- /* */
- /****************************************************************************************/
- /* */
- /* Version History: */
- /* */
- /* */
- /* Sunday 05/14/95 Separated Flight Simulator from Calculator Program */
- /* */
- /* */
- /* */
- /* */
- /* */
- /* */
- /****************************************************************************************/
- /* Current place of activity: */
- /* */
- /* /* look for this error */ /* */
- /* /* error?bug? */ /* */
- /* Things to do: in the matrix buttons there is sto plus code to be written */
- /* underneath sqrt button likewise */
- /* search for (gState & sWait) */
- /* */
- /* search for (gState & matrix) */
- /* */
- /* the matrix buttons need code for the non-User mode */
- /* */
- /* /* here is my place */ /* */
- /* use Courier 9 bold to display matrix elements with the List Manager windows */
- /* */
- /* */
- /****************************************************************************************/
-
- #pragma mark end_history
-
- /*****************************************************************/
- /* I N C L U D E S
- /*****************************************************************/
- #include <Quickdraw.h>
- #ifndef __GLO__
- #include "Globals.h"
- #endif
- #ifndef __C14__
- #include "PredatorPrey.h"
- #endif
- #ifndef __CUP__
- #include "calc_update.h"
- #endif
- #ifndef __CMO__
- #include "calc_mousedown.h"
- #endif
-
-
- #include <string.h>
- #ifndef __EVL__
- #include "EventLoop.h"
- #endif
- #ifndef __DOS__
- #include "DoScrap.h"
- #endif
- #ifndef __RED__
- #include "ResourceDefs.h"
- #endif
- #ifndef __C14D__
- #include "PredatorPreyData.h"
- #endif
- #ifndef __CIN__
- #include "calc_inits.h"
- #endif
- #ifndef __CFL__
- #include "calc_files.h"
- #endif
- #ifndef __DIS__
- #include "Dispatcher.h"
- #endif
- #ifndef __HCP__
- #include "HelpCloseProc.h"
- #endif
- #ifndef __HDP__
- #include "HelpDrawProc.h"
- #endif
- #ifndef __HGP__
- #include "HelpGetProc.h"
- #endif
- #ifndef __AEV__
- #include "HelpWindowProc.h"
- #endif
-
- #ifndef __MAP__
- #include "myActionProc.h"
- #endif
- #ifndef __MCL__
- #include "myClickLoop.h"
- #endif
- #ifndef __WW__
- #include "WhichWindow.h"
- #endif
- /*#include "AEvent.h"*/
- #ifndef __FIM__
- #include "FileM.h"
- #endif
- /*#include "GetMyHelpProc.h"*/
- #ifndef __HE__
- #include "Help.h"
- #endif
- #ifndef __MWI__
- #include "MainWindow.h"
- #endif
- #ifndef __MIS__
- #include "Miscellany.h"
- #endif
- #ifndef __SC__
- #include "Scrolling.h"
- #endif
- #ifndef __WA__
- #include "WindowAids.h"
- #endif
- #ifndef __WIN__
- #include "Windowing.h"
- #endif
- /*#include "calc_prog_list.h"*/
- #ifndef __CDO__
- #include "calc_dork.h"
- #endif
- #ifndef __CCE__
- #include "calc_contents.h"
- #endif
- #ifndef __TI__
- #include "trick.h"
- #endif
- #ifndef __CAC__
- #include "calc_activate.h"
- #endif
- #ifndef __CCR__
- #include "calc_controls.h"
- #endif
- #ifndef __CDI__
- #include "calc_dipshit.h"
- #endif
-
- #ifndef __DIA__
- #include "DialogAids.h"
- #endif
- #include "MainMenu.h"
- #include "windows.h"
- /*#include <asm.h>*/
- /*#include <math881.c>*/
- #include "AEvent.h"
-
- /********************************************************************
- /* G L O B A L V A R I A B L E D E C L A R A T I O N S
- /********************************************************************/
-
- /* #define NULL '\0' */
-
- #define MaxPoints 2500
-
-
- #define DoneButton 1
- #define Field3 3
- #define Field4 4
- #define Field5 5
- #define Field6 6
-
- /*extern mapstruct map;*/
-
- WindowPtr theWPtr = 0L;
- WindowPtr theRunWPtr = 0L;
- CharsHandle theCharsHndl;
- CharsHandle theChars2Hndl;
-
- ControlHandle theVScroll = 0L, theHScroll = 0L;
- ControlHandle theRunVScroll = 0L, theRunHScroll = 0L;
-
- char changed;
- char Rchanged;
- extern int defaultFont,defaultFontSize;
-
- Str255 theFileName = "\pPredPreyData";
- Str255 bufferOne;
- Str255 bufferTwo;
- Str255 bufferTwe;
- /*static */short theVRefNum;
- Cursor fingerCursor;
- Cursor questCursor;
- Cursor arrow,waitCursor;
- /*Boolean scrapDirty;*/
- /*int errno;*/
- long gInt[10],rTemp;
- long prCount; /**/
- long gTime;
- StringPtr theVolName;
- Ptr gDsplyPtr;
- Ptr mapPtr;
-
- short qRefNum;
- short pRefNum;
- short gErrorFlag/* = 0*/;
- short gWindowState;
- long gsState;
- long gState = 0x00000000;
- long delayTime = 70;
- Boolean gBroken;
- short gtoChs;
- short goWhere;
- Boolean gLoadProgEnabled = FALSE;
- double_t gDSEbuffer,gISGbuffer;
- double_t thisIsFucked;
- short tries = 0;
- short gVect1;
- short gVect2;
- Boolean gFirstTickGot = FALSE;
- Boolean gSecondTickGot = FALSE;
- Boolean gFirstCoordGot = FALSE;
- Boolean gWhichCoordFirst = 1;
- unsigned long gFirstTick;
- unsigned long gSecondTick;
- Boolean gGotVector;
- Boolean hasPlot;
-
- /* flags */
-
- /*double whichRegn,whichReg0n;*/
- long posN;
- long numN;
-
- Boolean oldWay = TRUE;
- Boolean useColor[7];
-
- WindowPtr gMy_windows[MY_WINDOW_MAX + 1];
- WindowPtr lastPtr;
- WindowPtr preyPtr;
- long gWindow_count = 0;
- Ptr gPre_allocated_block = NIL;
-
- Rect gArrow_box;
- Rect gCircle_box;
- Rect gSquare_box;
- Rect gCube_box;
- Rect gHouse_box;
- Rect gBackGrnd_box;
-
- Rect gPalette_frame;
-
- Rect gXrotation_box;
- Rect gYrotation_box;
- Rect gZrotation_box;
- Rect gNegXrotation_box;
- Rect gNegYrotation_box;
- Rect gNegZrotation_box;
- Rect gXrot_text_box;
- Rect gYrot_text_box;
- Rect gZrot_text_box;
- Rect gRot_OK_box;
- Rect gRot_Cancel_box;
-
- Rect gRotation_frame;
-
- Rect gDoManyRotation_box;
-
- Rect gDoRotateLeft_box;
- Rect gDoRotateRight_box;
- Rect gDoRotateUp_box;
- Rect gDoRotateDown_box;
- Rect gDoMoveIn_box;
- Rect gDoMoveOut_box;
-
- Rect gDoPitchUp_box;
- Rect gDoPitchDn_box;
- Rect gDoYawLft_box;
- Rect gDoYawRt_box;
- Rect gDoBankLft_box;
- Rect gDoBankRt_box;
-
- Rect gMovement_frame;
- Rect gPlaneControl_frame;
-
- Rect gXstretch_box;
- Rect gYstretch_box;
- Rect gZstretch_box;
- Rect gNegXstretch_box;
- Rect gNegYstretch_box;
- Rect gNegZstretch_box;
- Rect gXstr_text_box;
- Rect gYstr_text_box;
- Rect gZstr_text_box;
- Rect gStr_OK_box;
- Rect gStr_Cancel_box;
- Rect gStretch_frame;
- Rect gFirstCalcIcon,gSecondCalcIcon,gThirdCalcIcon;
- Rect gFourthCalcIcon,gFifthCalcIcon,gSixthCalcIcon;
-
- Boolean gIsWizard;
- Boolean stillWizard;
- Boolean WizAttempt;
- Boolean PassAttempt;
- Boolean preRegistered = FALSE;
- Boolean gHelpNot;
-
- ListHandle helpList; /* handle for List Manager */
-
- long helpLong; /* for help facility */
- Rect helpRect = {26,164, 214,398}; /* for help facility */
- Handle helpHandle; /* work handle for help */
-
- Point nextTextPosit; /* Position of next text window */
- /*RgnHandle workRegionH;*/ /* work handle for TE redraw */
- struct wTblStruct /* space for some window info */
- windTbl[windMax]; /* table of many of the above */
- long qCount;
- short iRefNum;
- double aaa[MaxPoints][3];
- short kNumMyHelpItems;
-
-
- /*****************************************************************/
- /* P R O T O T Y P E S
- /*****************************************************************/
- extern Boolean UpdateWindow (WindowPtr whichWindow);
- //extern void UpdateMenus (void);
- void main (void);
- void MainLoop (void);
- void HandleEvent (long *innerSel,long *outerSel);
- void DoKeystroke (void);
- void unload_world (void);
- /*****************************************************************/
- /*****************************************************************/
- /* */
- /* R O U T I N E S */
- /* */
- /*****************************************************************/
- /*****************************************************************/
-
-
- /*****************************************************************/
- /* m a i n - Start of main program.
- /*****************************************************************/
- /********************** Main ************************/
- void main(void)
-
- {
- iRefNum = CurResFile();
- qCount = 0;
- gStrCnt = 0;
- gFormatFlag = 0;
- gErrorFlag = 0;
- gIsWizard = TRUE;
- stillWizard = FALSE;
- hasPlot = FALSE;
-
-
- init_ROM(); /* call initialization routine */
-
-
- //#if GENERATINGCFM
- // DebugStr("\pGENERATINGCFM");
- //#endif
-
- /* *------------- in calc_inits.c */
- /* | */
- /* v */
- GetEnvir( &theVRefNum );/* returns Volume ID (or working dir) of open System file */
- DoGetSysConfig();
-
- SetUpCursors(); /* calc_inits.c */
- InitScrap();
- InitGlobals();
- //UseResFile(iRefNum);
- #ifdef quiet
- ;
- #else
- SplashScreen (); /* calc_inits.c */
- DoTheShare(); /* calc_inits.c */
- #endif
- WindowInit(); /* calc_inits.c */
- MenuBarInit(); /* calc_inits.c */
- LoadPicture(); /* calc_inits.c */
- SetUpDragRect(); /* calc_inits.c */
- SetUpFile ( &theFileName, &theVRefNum ); /* In calc_files.c *//* Str255 theFileName = "\pPredPreyData"; */
-
- //SetUpLogFile ( 0, &theLogFileName, &theVRefNum ); /* In calc_files.c */
-
- DoShareCopy(); /* in calc_dipshit.c */
-
- MainLoop();
- }
-
-
-
- /*****************************************************************/
- /******************** unload_world *******************************/
- /*****************************************************************/
-
- void unload_world(void)
-
- {
- UnloadSeg(inits_seg);
-
- UnloadSeg(one_button_seg);
- UnloadSeg(three_button_seg);
- UnloadSeg(five_button_seg);
- UnloadSeg(seven_button_seg);
- UnloadSeg(nine_button_seg);
- UnloadSeg(decimal_button_seg);
- UnloadSeg(enter_button_seg);
- UnloadSeg(sin_button_seg);
- UnloadSeg(tan_button_seg);
- UnloadSeg(sqrt_button_seg);
- UnloadSeg(etox_button_seg);
- UnloadSeg(tentox_button_seg);
- UnloadSeg(ytox_button_seg);
- UnloadSeg(inverse_button_seg);
- UnloadSeg(rolldn_button_seg);
- UnloadSeg(mousedown_seg);
- UnloadSeg(activate_seg);
- UnloadSeg(update_seg);
- UnloadSeg(handlebutton_seg);
- UnloadSeg(memory_manager_seg);
- UnloadSeg(matrix_funcs_seg);
- UnloadSeg(arithmetic_seg);
- UnloadSeg(help_seg);
- UnloadSeg(program_seg);
- UnloadSeg(dork_seg);
- UnloadSeg(dipshit_seg);
- UnloadSeg(wizard_seg);
- UnloadSeg(C14Data_seg);
-
- UnloadSeg(contents_seg); /****/
- UnloadSeg(controls_seg); /****/
-
- UnloadSeg(file_seg);
- UnloadSeg(trick_seg);
- UnloadSeg(HelpCloseSeg);
- UnloadSeg(HelpDrawSeg);
- UnloadSeg(HelpGetSeg);
- UnloadSeg(HelpWindowSeg);
- UnloadSeg(MouseDownSeg);
- UnloadSeg(myActionSeg);
- UnloadSeg(myClickLoopSeg);
- UnloadSeg(WhichWindowSeg);
- UnloadSeg(DispatcherSeg);
- UnloadSeg(DoScrapSeg);
- UnloadSeg(EventLoopSeg);
- UnloadSeg(FileMSeg);
- UnloadSeg(GlobalsSeg);
- UnloadSeg(MainWindowSeg);
- UnloadSeg(MiscellanySeg);
- UnloadSeg(ScrollingSeg);
- UnloadSeg(WindowAidsSeg);
- UnloadSeg(WindowingSeg);
- /* UnloadSeg(progList_seg);*/
-
- return;
-
- } /* end of unload_world() */
-
-
-
- /********************** MainLoop ************************/
- void MainLoop(void)
- {
- long innerSel,outerSel;
-
-
- gDone = FALSE;
- gWNEImplemented = WNE_is_implemented();
-
- while( gDone == FALSE )
- {
- HandleEvent(&innerSel,&outerSel);
- }
- }
-
- /********************** HandleEvent ************************/
- void HandleEvent(long *innerSel,long *outerSel)
- {
- Boolean result,ignore_result,fineMove = false;
- short myItemHit;
- short i,weapon_type;
- char theChar;
- long charCode;
- KeyMap theKeys;
- WindowPtr wizPtr;
- GrafPtr wOldPort;
- short itemHit,whichCalc;
- long dummy;
- Point pt;
- /* cw5 */ //SndListHandle sound;
- //Handle Meep;
- //SndListHandle Jeep;
- OSErr errCode,iErr;
- WindowPtr wPtr;
- WObjsHandle w_objs_hndl;
- SndChannelPtr Chan00;
- Boolean quietNow = 0;
- long palSet;
- short vPtChoice,focalPtChoice;
-
- if(lastPtr != NIL)
- {
- w_objs_hndl = (WObjsHandle)GetWRefCon(lastPtr);
- }
- /**********************************************************/
-
- qCount++;
- if(qCount >= 10)
- {
- qCount = 0;
- if((wPtr = FrontWindow()) != NIL)
- {
- if(one_of_mine(wPtr) || wPtr == gRotateBox || wPtr == gStretchBox)
- {
- *innerSel = 0;
- *outerSel = 0;
- if((**w_objs_hndl).arms_selected == 1 && (**w_objs_hndl).hasTargets)
- {
- TrackTarget(innerSel,outerSel);
- if(*innerSel & 0x00111111)
- {
- Chan00 = (SndChannelPtr)NewPtrClear(sizeof(SndChannel));
- if(Chan00 != nil)
- {
- Chan00->qLength = stdQLength;
- iErr = SndNewChannel(&Chan00,sampledSynth,initMono,nil);
- }
- /* cw5 */ //Meep = GetResource ('snd ', 1410);
- //Jeep = (SndListHandle)Meep;
- //if (Meep != NULL)
- //{
- // for(i = 0;i <=5;i++)
- // {
- // errCode = SndPlay (Chan00, Jeep, true); //errCode = SndPlay (NULL, guns0, false);
- // Delay(3L,&dummy);
- // }
- /* cw5 */ //}
- iErr = SndDisposeChannel(Chan00,quietNow);
- }
- else if(*outerSel & 0x00111111 /* && *innerSel ^ 0x00111111*/)
- {
- /* cw5 */ //Meep = GetResource ('snd ', 1400);
- /* cw5 */ //SndPlay (NULL, Meep, false);
- }
- }
- }
- }
- }
- /**********************************************************/
- if ( gWNEImplemented )
- {
- ignore_result = WaitNextEvent( everyEvent,
- &gTheEvent,
- SLEEP,
- NIL_MOUSE_REGION );
- }
- else
- {
- SystemTask();
- ignore_result = GetNextEvent( everyEvent,
- &gTheEvent );
- }
- wPtr = FrontWindow();
-
- switch ( gTheEvent.what )
- {
- case nullEvent:
-
- break;
- case mouseDown:
- HandleMouseDown(); /* calc_mousedown.c */
- break;
- case mouseUp:
- break;
- case keyDown:
- case autoKey:
- wPtr = FrontWindow(); /*FindWindow( gTheEvent.where, &wPtr );*/
- theChar = gTheEvent.message & charCodeMask;
- if ((( gTheEvent.modifiers & cmdKey )/* && ( gTheEvent.modifiers & optionKey )*/) != 0)
- HandleMenuChoice( MenuKey( theChar ) );
- else if((gTheEvent.modifiers & optionKey)&&(gTheEvent.modifiers & controlKey))
- {
- if ((theChar == 23)) /* control-option-w */
- {
- GetMouse(&pt);
- if (PtInRect(pt, &gDivideRect ))
- {
- DoTheWiz(); /* in calc_dipshit.c */
- }
- }
- if ((theChar == 16) && (gIsWizard)) /* control-option-p */
- {
- DoTheShare(); /* in calc_inits.c */
- }
- if ((theChar == 19) && (gIsWizard)) /* control-option-s */
- {
- DoSetPassword();
- }
- if ((theChar == 25) && (stillWizard)) /* control-option-y */
- {
- /* cw5 */ //sound = GetResource ('snd ', MutateID);
- //if (sound != NULL)
- //{
- // errCode = SndPlay (NULL, sound, false);
- /* cw5 */ //}
- if(gIsWizard)
- {
- gIsWizard = FALSE;
- DelMenuItem( GetMHandle(FILE_MENU_ID), 6 );
- InsMenuItem( GetMHandle(FILE_MENU_ID), "\pLoad Program/L", 5 );
- DelMenuItem( GetMHandle(FILE_MENU_ID), 7 );
- InsMenuItem( GetMHandle(FILE_MENU_ID), "\pLoad Data/L", 6 );
- }
- else
- {
- gIsWizard = TRUE;
- DelMenuItem( GetMHandle(FILE_MENU_ID), 6 );
- InsMenuItem( GetMHandle(FILE_MENU_ID), "\pOpen Program/L", 5 );
- DelMenuItem( GetMHandle(FILE_MENU_ID), 7 );
- InsMenuItem( GetMHandle(FILE_MENU_ID), "\pOpen Data/L", 6 );
- }
- if(!gLoadProgEnabled)
- {
- DisableItem(GetMHandle(FILE_MENU_ID), 6);
- DisableItem(GetMHandle(FILE_MENU_ID), 7);
- }
- }
- if((theChar == 96))
- {
- /* Do option-control-` */
- }
-
- }
-
- /* else if((gTheEvent.modifiers & optionKey)&&(gTheEvent.modifiers & cmdKey))*/
- /* {*/
- /* }*/
-
- else
- {
- charCode = gTheEvent.message & charCodeMask;
-
- switch(charCode)
- {
- case 9: /* tab char */
- wPtr = FrontWindow();
- if(one_of_mine(wPtr) || wPtr == gRotateBox || wPtr == gStretchBox)
- {
- palSet = (**w_objs_hndl).paletteSetting;
- if(palSet == CIRCLE_OBJ)
- {
- weapon_type = (**w_objs_hndl).armament_type;
- if(weapon_type == 0) draw_palette(lastPtr); /* in calc_update.c */
- else if(weapon_type == 1)
- {
- if((**w_objs_hndl).arms_selected == 0) (**w_objs_hndl).arms_selected = 1;
- else if((**w_objs_hndl).arms_selected == 1) (**w_objs_hndl).arms_selected = 0;
- draw_palette(lastPtr); /* in calc_update.c */
- }
- else if (weapon_type == 2)
- {
- if((**w_objs_hndl).arms_selected == 0) (**w_objs_hndl).arms_selected = 1;
- else if((**w_objs_hndl).arms_selected == 1) (**w_objs_hndl).arms_selected = 2;
- else if((**w_objs_hndl).arms_selected == 2) (**w_objs_hndl).arms_selected = 0;
- draw_palette(lastPtr); /* in calc_update.c */
- }
- }
- else if(palSet == SQUARE_OBJ)
- {
- vPtChoice = (**w_objs_hndl).vPtNo;
- switch(vPtChoice)
- {
- case 0:
- (**w_objs_hndl).xvPt = 100;
- (**w_objs_hndl).yvPt = 100;
- (**w_objs_hndl).vPtNo = 1;
- break;
- case 1:
- (**w_objs_hndl).xvPt = 200;
- (**w_objs_hndl).yvPt = 100;
- (**w_objs_hndl).vPtNo = 2;
- break;
- case 2:
- (**w_objs_hndl).xvPt = 300;
- (**w_objs_hndl).yvPt = 100;
- (**w_objs_hndl).vPtNo = 3;
- break;
- case 3:
- (**w_objs_hndl).xvPt = 400;
- (**w_objs_hndl).yvPt = 100;
- (**w_objs_hndl).vPtNo = 4;
- break;
- case 4:
- (**w_objs_hndl).xvPt = 500;
- (**w_objs_hndl).yvPt = 100;
- (**w_objs_hndl).vPtNo = 5;
- break;
- case 5:
- (**w_objs_hndl).xvPt = 600;
- (**w_objs_hndl).yvPt = 100;
- (**w_objs_hndl).vPtNo = 6;
- break;
- case 6:
- (**w_objs_hndl).xvPt = 100;
- (**w_objs_hndl).yvPt = 200;
- (**w_objs_hndl).vPtNo = 7;
- break;
- case 7:
- (**w_objs_hndl).xvPt = 200;
- (**w_objs_hndl).yvPt = 200;
- (**w_objs_hndl).vPtNo = 8;
- break;
- case 8:
- (**w_objs_hndl).xvPt = 300;
- (**w_objs_hndl).yvPt = 200;
- (**w_objs_hndl).vPtNo = 9;
- break;
- case 9:
- (**w_objs_hndl).xvPt = 400;
- (**w_objs_hndl).yvPt = 200;
- (**w_objs_hndl).vPtNo = 10;
- break;
- case 10:
- (**w_objs_hndl).xvPt = 500;
- (**w_objs_hndl).yvPt = 200;
- (**w_objs_hndl).vPtNo = 11;
- break;
- case 11:
- (**w_objs_hndl).xvPt = 600;
- (**w_objs_hndl).yvPt = 200;
- (**w_objs_hndl).vPtNo = 12;
- break;
- case 12:
- (**w_objs_hndl).xvPt = 100;
- (**w_objs_hndl).yvPt = 300;
- (**w_objs_hndl).vPtNo =13;
- break;
- case 13:
- (**w_objs_hndl).xvPt = 200;
- (**w_objs_hndl).yvPt = 300;
- (**w_objs_hndl).vPtNo = 14;
- break;
- case 14:
- (**w_objs_hndl).xvPt = 300;
- (**w_objs_hndl).yvPt = 300;
- (**w_objs_hndl).vPtNo = 15;
- break;
- case 15:
- (**w_objs_hndl).xvPt = 400;
- (**w_objs_hndl).yvPt = 300;
- (**w_objs_hndl).vPtNo = 16;
- break;
- case 16:
- (**w_objs_hndl).xvPt = 500;
- (**w_objs_hndl).yvPt = 300;
- (**w_objs_hndl).vPtNo = 17;
- break;
- case 17:
- (**w_objs_hndl).xvPt = 600;
- (**w_objs_hndl).yvPt = 300;
- (**w_objs_hndl).vPtNo = 18;
- break;
- case 18:
- (**w_objs_hndl).xvPt = 100;
- (**w_objs_hndl).yvPt = 400;
- (**w_objs_hndl).vPtNo = 19;
- break;
- case 19:
- (**w_objs_hndl).xvPt = 200;
- (**w_objs_hndl).yvPt = 400;
- (**w_objs_hndl).vPtNo = 20;
- break;
- case 20:
- (**w_objs_hndl).xvPt = 300;
- (**w_objs_hndl).yvPt = 400;
- (**w_objs_hndl).vPtNo = 21;
- break;
- case 21:
- (**w_objs_hndl).xvPt = 400;
- (**w_objs_hndl).yvPt = 400;
- (**w_objs_hndl).vPtNo = 22;
- break;
- case 22:
- (**w_objs_hndl).xvPt = 500;
- (**w_objs_hndl).yvPt = 400;
- (**w_objs_hndl).vPtNo = 23;
- break;
- case 23:
- (**w_objs_hndl).xvPt = 600;
- (**w_objs_hndl).yvPt = 400;
- (**w_objs_hndl).vPtNo = 0;
- break;
- }
- InvalRect(&lastPtr->portRect);
- do_update(lastPtr);
- }
- else if(palSet == T_BACKGRND_OBJ || palSet == BACKGRND_OBJ)
- {
- focalPtChoice = (**w_objs_hndl).focalPtNo;
- switch(focalPtChoice)
- {
- case 0:
- (**w_objs_hndl).focalPtNo = 1;
- (**w_objs_hndl).focalLn = 1000;
- break;
- case 1:
- (**w_objs_hndl).focalPtNo = 2;
- (**w_objs_hndl).focalLn = 500;
- break;
- case 2:
- (**w_objs_hndl).focalPtNo = 3;
- (**w_objs_hndl).focalLn = 400;
- break;
- case 3:
- (**w_objs_hndl).focalPtNo = 4;
- (**w_objs_hndl).focalLn = 300;
- break;
- case 4:
- (**w_objs_hndl).focalPtNo = 5;
- (**w_objs_hndl).focalLn = 200;
- break;
- case 5:
- (**w_objs_hndl).focalPtNo = 6;
- (**w_objs_hndl).focalLn = 100;
- break;
- case 6:
- (**w_objs_hndl).focalPtNo = 7;
- (**w_objs_hndl).focalLn = 50;
- break;
- case 7:
- (**w_objs_hndl).focalPtNo = 8;
- (**w_objs_hndl).focalLn = 20;
- break;
- case 8:
- (**w_objs_hndl).focalPtNo = 9;
- (**w_objs_hndl).focalLn = 10;
- break;
- case 9:
- (**w_objs_hndl).focalPtNo = 0;
- (**w_objs_hndl).focalLn = 10000;
- break;
- }
- InvalRect(&lastPtr->portRect);
- do_update(lastPtr);
- }
- }
-
- break;
- case 32: /* space bar */
- wPtr = FrontWindow();
- if(one_of_mine(wPtr) || wPtr == gRotateBox || wPtr == gStretchBox)
- FireGuns(innerSel,outerSel); /* calc_dork.c */
- //if((**w_objs_hndl).arms_selected == 1)
- // GuideMissle(innerSel,outerSel); /* calc_dork.c */
- break;
- }
- }
- break;
- case keyUp:
- break;
- case activateEvt:
- do_activate( (WindowPtr) gTheEvent.message,
- (gTheEvent.modifiers & activeFlag) != 0);
- break; /* located in calc_activate.c */
- case kHighLevelEvent:
- DoHighLevelEvent (&gTheEvent);
- break;
-
- case updateEvt:
- if ( one_of_mine((WindowPtr)gTheEvent.message )) /* one_of… in this file */
- {
- do_update((WindowPtr) gTheEvent.message); /* ie, if graphics window */
- }
- else if( (WindowPtr)gTheEvent.message == gRotateBox )
- {
- SetPort(gRotateBox);
- BeginUpdate(gRotateBox);
- do_rotation_subject(gRotateBox,fineMove); /* in calc_contents.c */
- EndUpdate(gRotateBox);
- }
- else if( (WindowPtr)gTheEvent.message == gStretchBox )
- {
- SetPort(gStretchBox);
- BeginUpdate(gStretchBox);
- do_stretch_subject(gStretchBox);
- EndUpdate(gStretchBox);
- }
- break;
- }
- unload_world(); /* unlock any segments used in last event process */
- if(gPre_allocated_block == NIL)
- {
- gPre_allocated_block = NewPtr(sizeof(CWindowRecord));
- if(gPre_allocated_block == NIL)
- {
- #ifdef powerc
- StopAlert(OUT_OF_MEM, (UniversalProcPtr)NIL);
- #else
- StopAlert(OUT_OF_MEM, 0/*NULL*/);
- #endif /* powerc */
- }
- }
- }
- /********************** End of HandleEvent *********************/
-
-
-
-
-
-
-
-
- /********************** cat_strings ******************************/
- void cat_strings(char *srce_str,char *dest_str,unsigned long dest_max)
- /*short dest_max;*/
- {
- size_t new_max;
-
- new_max = dest_max;
- /* convert Pascal strings to C strings */
-
- srce_str = PtoCstr((StringPtr)srce_str); /* p. 207 of User Manual */
- dest_str = PtoCstr((StringPtr)dest_str);
-
- /* concatenate the source onto the destination */
-
- srce_str = strncat (dest_str, srce_str, dest_max);
-
- /* convert the C strings back to Pascal */
-
- /* srce_str = (char*)CtoPstr(&srce_str);*/
- /* dest_str = (char*)CtoPstr(&dest_str);*/
- srce_str = (char*)CtoPstr(srce_str); /* here is a change */
- //dest_str = (char*)CtoPstr(dest_str); /* here is a change */
-
- } /* end of cat_strings() */
-
-
- /********************** one_of_mine ******************************/
- short one_of_mine(WindowPtr wPtr)
- {
- short n;
-
- if(wPtr == NIL) return(0);
-
- for(n = 1; n < MY_WINDOW_MAX+1; n++)
- if(gMy_windows[n] == wPtr)
- {
- lastPtr = wPtr;
- return(n);
- }
- return(0);
-
- } /* end of one_of_mine() */
-
-
- /********************* clip_4_palette ****************************/
- void clip_4_palette(WindowPtr wPtr)
- {
- RgnHandle saved_clip, palette_clip, w_frame_clip;
- Rect draw_bounds;
- short doc_length, doc_width;
-
-
- palette_clip = NewRgn();
- RectRgn (palette_clip, &gPalette_frame);
-
- draw_bounds = wPtr->portRect; /* set the drawing rect... */
- draw_bounds.right -= 15;
- draw_bounds.bottom -= 15;
-
- w_frame_clip = NewRgn();
- RectRgn (w_frame_clip, &draw_bounds);
-
- DiffRgn(w_frame_clip, palette_clip, w_frame_clip); /* subtract the two */
-
- SetClip(w_frame_clip); /* set the clip region */
-
- DisposeRgn(palette_clip); /* clean-up */
- DisposeRgn(w_frame_clip);
-
- } /* end of clip_4_palette() */
-
-
-
- /********************** inval_object *****************************/
- void inval_object(WindowPtr wPtr, short index)
- {
- Point offset;
- Rect obj_rect;
- WObjsHandle w_objs_hndl;
-
- /************* Find size and location of the object **********/
-
-
- w_objs_hndl = (WObjsHandle)GetWRefCon(wPtr);
- offset = (**w_objs_hndl).scrollAmount;
-
- obj_rect = (**w_objs_hndl).object[index].bounds;
- OffsetRect(&obj_rect, -offset.h, -offset.v);
-
- /************* Let the update routine take care of it... **********/
-
- InvalRect(&obj_rect);
-
- return;
-
- } /* end of inval_object() */
-
-
- /*----------*/
- void DoKeystroke ()
- {
- short charCode;
- char ch;
-
- charCode = gTheEvent.message & charCodeMask;
- ch = charCode;
-
- if ((gTheEvent.modifiers & cmdKey) != 0) {
- if (gTheEvent.what != autoKey) {
- DoMenu (MenuKey (ch));
- SysBeep (1);
- }
- } else {
- if (curWindow == NULL) {
- SysBeep (1);
- } else {
- TypeInWindow (ch); /* Dispatcher.c */
- }
- }
- } /*DoKeystroke*/
-
-
- //************************************************************************
-
- void died (char desc[255], int code, int ref)
- {
- /* nasty error has occurred - report it and quit */
- int go;
- char a[50], b[50];
-
- CtoPstr (desc);
- NumToString (code, (StringPtr)a);
- NumToString (ref, (StringPtr)b);
- ParamText ((StringPtr)desc, (StringPtr)a, (StringPtr)b, NULL);
- go = Alert(131,NULL);
- ExitToShell();
- }
-
- //************************************************************************
-